#ifndef TTY_H
#define TTY_H
#include "sem.h"

#define TTY_OBUF_SIZE  512
#define TTY_IBUF_SIZE  512
#define TTY_NR         8

typedef struct _tty_fifo_t{
    char *buf; //buffer
    int size;//buffer size
    int read,write; //addr of read or write,or the index of array
    int count; //valid size
}tty_fifo_t;


#define TTY_OCRLF   (1<<0)
#define TTY_ICRLF   (1<<0)
#define TTY_IECHO   (1<<1)

#define TTY_CMD_ECHO 0x1

typedef struct _tty_t{
    char obuf[TTY_OBUF_SIZE];
    tty_fifo_t ofifo;
    sem_t osem;
    int oflags;


    char ibuf[TTY_IBUF_SIZE];
    tty_fifo_t ififo;
    sem_t isem;
    int iflags;


    int console_idx;//which tty to display , belongs to dev minor id, set when opened
}tty_t;

int tty_filo_put(tty_fifo_t *fifo,char c);
int tty_fifo_get(tty_fifo_t *fifo,char *c);


void tty_select(int console_idx);
void tty_in(char ch);
#endif